//
//  OAPageApproveVC.m
//  OA项目
//
//  Created by innofive on 2018/4/13.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAPageApproveVC.h"
#import "OAApprovelistManagerVC.h"
#import "OAAddWorklistManagerVC.h"
#import "OAExpenseslistManagerVC.h"
#import "OATravellistManagerVC.h"
#import "OAYongZhanglistManagerVC.h"
#import "OAYongZhanglistManagerVC.h"
#import "OADininglistMangerVC.h"
#import "OAMeetlistManagerVC.h"
#import "OATongYonglistMangerVC.h"
#import "OADianZiJiaoYilistMangerVC.h"
#import "OACarlistMangerVC.h"

#import "UIViewController+Action.h"
#import "OAPageApproveContentCell.h"
#import "OADissentComplaintsVC.h"

@interface OAPageApproveContent1VC()
@property(nonatomic,assign)CGFloat w;
@end

@implementation OAPageApproveContent1VC
- (void)viewDidLoad {
    [super viewDidLoad];
    
    _w = [UIScreen mainScreen].bounds.size.width/3;
}
-(void)onLoadViewByWillAppear:(UIView *)view
{
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.collectionView config:^(UICollectionView *collectionView) {
        [collectionView registerCellClass:@"OAPageApproveContentCell" forIdentifier:cell];
    }];
}

-(void)onLoadDataForPageNum:(NSInteger)pageNum
{
    WSELF(weakSelf);
    [ENGINE POST:apiCateList param:@{} parseClass:[OAApproveContentModel class] successBlock:^(id data) {
        [weakSelf.dataArr removeAllObjects];
        [weakSelf.dataArr addObjectsFromArray:data];
        [weakSelf.collectionView reloadData];
    } falieBlock:self.failedBlock errorBlock:self.errorBlock];
  
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    OAApproveContentModel * model = [self modelForIndexPath:indexPath];
    if (indexPath.row==0) {
        
        OAApprovelistManagerVC *vc = [OAApprovelistManagerVC new];
        vc.title = @"请假审批";
        vc.Id =model.cateId;
        [self pushToVC:vc];
    }
    else if (indexPath.row==1) {
        OAAddWorklistManagerVC *vc = [OAAddWorklistManagerVC new];
        vc.title = @"加班审批";
        [self pushToVC:vc];

    }
    else if (indexPath.row==2) {
     OAExpenseslistManagerVC *vc = [OAExpenseslistManagerVC new];
        vc.title = @"费用报销审核";
        [self pushToVC:vc];
        
    }
    else if (indexPath.row==3) {
        OATravellistManagerVC *vc = [OATravellistManagerVC new];
        vc.title = @"出差申请单";
        [self pushToVC:vc];

    }
    else if (indexPath.row==4)
    {
        
        OAYongZhanglistManagerVC *vc = [OAYongZhanglistManagerVC new];
        vc.title = @"用章审批";
        [self pushToVC:vc];
    }
    else if (indexPath.row==5)
    {

        OADininglistMangerVC *vc = [OADininglistMangerVC new];
        vc.title = @"用餐审批";
        [self pushToVC:vc];
    }
    else if (indexPath.row==6)
    {
        OAMeetlistManagerVC *vc = [OAMeetlistManagerVC new];
        vc.title = @"会议室审批";
        [self pushToVC:vc];
    }
    else if (indexPath.row==7)
    {
        OATongYonglistMangerVC *vc = [OATongYonglistMangerVC new];
        vc.title = @"通用审批";
        [self pushToVC:vc];
    }
    else if (indexPath.row==8)
    {
        OADianZiJiaoYilistMangerVC *vc = [OADianZiJiaoYilistMangerVC new];
        vc.title = @"电子交易平台合同审批";
        [self pushToVC:vc];
    }
    else if (indexPath.row==9)
    {
        OACarlistMangerVC *vc = [OACarlistMangerVC new];
        vc.title = @"汽车审批";
        [self pushToVC:vc];
        
    }
    else if (indexPath.row==10)
    {
        OADissentComplaintslistMangerVC *vc = [OADissentComplaintslistMangerVC new];
        vc.title = @"异议投诉";
        [self pushToVC:vc];
        
    }
}


-(MCCollVCellInfo *)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)layout cellForIndexPath:(NSIndexPath *)indexPath sectionAtIndex:(NSInteger)section IsSection:(BOOL)isSection
{
    return [MCCollVCellInfo configForCellId:cell Class:[OAPageApproveContentCell class] Line:0 Interitem:0 CollectionView:collectionView SizeCell:CGSizeMake(_w, _w) InsetsCell:UIEdgeInsetsZero IsSection:isSection];
}


@end


@interface OAPageApproveContent2VC()
@property(nonatomic,assign)CGFloat w;
@end


@implementation OAPageApproveContent2VC
- (void)viewDidLoad {
    [super viewDidLoad];

_w = [UIScreen mainScreen].bounds.size.width/2;
    
}
-(void)onLoadViewByWillAppear:(UIView *)view
{
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.collectionView config:^(UICollectionView *collectionView) {
        [collectionView registerCellClass:@"OAPageApproveContentCell" forIdentifier:cell];
    }];
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}
-(MCCollVCellInfo *)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)layout cellForIndexPath:(NSIndexPath *)indexPath sectionAtIndex:(NSInteger)section IsSection:(BOOL)isSection
{
    return [MCCollVCellInfo configForCellId:cell Class:[OAPageApproveContentCell class] Line:0 Interitem:0 CollectionView:collectionView SizeCell:CGSizeMake(_w, _w) InsetsCell:UIEdgeInsetsZero IsSection:isSection];
}


@end




@interface OAPageApproveVC()<WMPageControllerDelegate,WMPageControllerDataSource>
@property(nonatomic,strong)NSArray *Titles;
@end


@implementation OAPageApproveVC

- (instancetype)init
{
    if (self = [super init])
    {
        self.titleSizeNormal = kFitW(15);
        self.titleSizeSelected = kFitW(15);
        self.menuViewStyle = WMMenuViewStyleLine;
        self.menuItemWidth = [UIScreen mainScreen].bounds.size.width / self.Titles.count;
        self.titleColorSelected = hexCOLOR(@"B68839");
        self.progressWidth = kFitW(130);
        self.progressColor =hexCOLOR(@"B68839");
        self.titleColorNormal =[UIColor blackColor];
    }
    return self;
    
}

//视图将要显示时隐藏
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
}

//视图将要消失时取消隐藏
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    [self onSetupBackButton];
   
//    self.titleSizeNormal = kFitW(15);
//    self.titleSizeSelected = kFitW(15);
//    self.menuViewStyle = WMMenuViewStyleLine;
//    self.menuItemWidth = [UIScreen mainScreen].bounds.size.width / self.Titles.count;
   // self.titleColorSelected = [UIColor blackColor];
//    self.progressWidth = kFitW(130);
    //self.progressColor =hexCOLOR(@"29AEE2");
    //self.titleColorNormal =[UIColor blackColor];
    
    self.delegate = self;
    self.dataSource = self;
}

/**
 *  To inform how many child controllers will in `WMPageController`.
 *
 *  @param pageController The parent controller.
 *
 *  @return The value of child controllers's count.
 */
- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController
{
    return self.Titles.count;
}
- (__kindof UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index
{
    
    if (index==0) {

        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
        OAPageApproveContent1VC *vc = [[OAPageApproveContent1VC alloc]initWithCollectionViewLayout:flowLayout];
        return vc;
    }

    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    OAPageApproveContent2VC *vc = [[OAPageApproveContent2VC alloc]initWithCollectionViewLayout:flowLayout];

    return vc;
    
    
}
- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index
{
    return self.Titles[index];
}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForContentView:(WMScrollView *)contentView
{
    return CGRectMake(0,kFitH(40),self.view.frame.size.width,self.view.frame.size.height-kFitH(40));
}
- (CGRect)pageController:(WMPageController *)pageController preferredFrameForMenuView:(WMMenuView *)menuView
{
    return CGRectMake(0, 0,self.view.frame.size.width,kFitH(40));
}
-(NSArray *)Titles
{
    if (!_Titles) {
    _Titles = @[@"OA审核流程",@"电子交易平台审核"];
    }
    return _Titles;
}
@end
